#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.basic.module.permission.mapper;

import ${package}.common.bean.po.Element;
import ${package}.common.bean.po.ElementPermission;
import ${package}.common.bean.po.Menu;
import ${package}.common.bean.po.MenuPermission;
import ${package}.common.bean.po.Operate;
import ${package}.common.bean.po.OperatePermission;
import ${package}.common.bean.po.PermissionType;
import ${package}.common.bean.po.Role;
import ${package}.common.bean.po.RolePermission;
import ${package}.common.bean.vo.UserPermissUrlVo;
import ${package}.common.bean.vo.UserPermissionVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Description: 权限
 *
 * @author wupanhua
 * @date 2019/8/6 15:28
 *
 * <pre>
 *              ${copyright}
 *      Copyright (c) 2019. All Rights Reserved.
 * </pre>
 */
@Repository
public interface PermissionMapper {

    /**
     * Description:
     * <根据角色主键获取角色权限>
     * @author wupanhua
     * @date 10:00 2019/8/7
     * @param roleId 1
     * @return java.util.List<RolePermission>
     **/
    List<RolePermission> queryPermissionByRoleKey(Long roleId);

    /**
     * Description:
     * <新增权限>
     * @author wupanhua
     * @date 10:03 2019/8/7
     * @param rolePermission 1
     **/
    void insertRolePermission(RolePermission rolePermission);

    /**
     * Description:
     * <根据菜单主键和权限主键删除菜单权限>
     * @author wupanhua
     * @date 10:03 2019/8/7
     * @param menuKey 1
     * @param permissionKey 2
     **/
    void deleteMenuPermissionByMenuKeyAndPermissionKey(@Param("menuKey") Long menuKey, @Param("permissionKey") Long permissionKey);

    /**
     * Description:
     * <删除角色的全部菜单权限>
     * @author zhangwy
     * @date 10:04 2019/8/7
     * @param id 1
     **/
    void deleteMenuPermissionByPermissionId(Long id);

    /**
     * Description:
     * <插入菜单权限表>
     * @author wupanhua
     * @date 10:04 2019/8/7
     * @param menuPermission 1
     **/
    void insertMenuPermission(MenuPermission menuPermission);

    /**
     * Description:
     * <根据权限主键和操作元素主键删除页面元素权限>
     * @author wupanhua
     * @date 10:05 2019/8/7
     * @param elementKey 1
     * @param permissionKey 2
     **/
    void deleteElementPermissionByPermissionKeyAndElementKey(@Param("elementKey") Long elementKey, @Param("permissionKey") Long permissionKey);

    /**
     * Description:
     * <删除角色拥有的全部页面元素权限>
     * @author pig
     * @date 10:06 2019/8/7
     * @param id 1
     **/
    void deleteElementPermissionByPermissionId(Long id);

    /**
     * Description:
     * <插入页面元素权限>
     * @author elementPermission
     * @date 10:06 2019/8/7
     * @param elementPermission 1
     **/
    void insertElementPermission(ElementPermission elementPermission);

    /**
     * Description:
     * <根据权限主键和操作链接主键删除操作链接权限>
     * @author wupanhua
     * @date 10:07 2019/8/7
     * @param operateKey 1
     * @param permissionKey 2
     **/
    void deleteOperatePermissionByPermissionKeyAndOperateKey(@Param("operateKey") Long operateKey, @Param("permissionKey") Long permissionKey);

    /**
     * Description:
     * <删除角色所拥有的全部操作元素权限>
     * @author pig
     * @date 10:07 2019/8/7
     * @param id 1
     **/
    void deleteOperatePermissionByPermissionId(Long id);

    /**
     * Description:
     * <插入操作链接权限>
     * @author wupanhua
     * @date 10:07 2019/8/7
     * @param operatePermission 1
     **/
    void insertOperatePermission(OperatePermission operatePermission);

    /**
     * Description:
     * <获取所有菜单权限>
     * @author wupanhua
     * @date 10:08 2019/8/7
     * @return java.util.List<PermissionType>
     **/
    List<PermissionType> queryAllPermissionType();

    /**
     * Description:
     * <根据角色权限主键获取菜单权限>
     * @author wupanhua
     * @date 10:08 2019/8/7
     * @param key 1
     * @return java.util.List<MenuPermission>
     **/
    List<MenuPermission> queryMenuPermissionByRolePermissionKey(Long key);

    /**
     * Description:
     * <根据角色权限主键获取元素权限>
     * @author wupanhua
     * @date 10:08 2019/8/7
     * @param key 1
     * @return java.util.List<ElementPermission>
     **/
    List<ElementPermission> queryElementPermissionByRolePermissionKey(Long key);

    /**
     * Description:
     * <根据角色权限主键获取操作权限>
     * @author wupanhua
     * @date 10:09 2019/8/7
     * @param key 1
     * @return java.util.List<OperatePermission>
     **/
    List<OperatePermission> queryOperatePermissionByRolePermissionKey(Long key);

    /**
     * Description:
     * <根据角色权限获取菜单权限>
     * @author wupanhua
     * @date 10:09 2019/8/7
     * @return java.util.List<UserPermissUrlVo>
     **/
    List<UserPermissUrlVo> queryMenuPermission();

    /**
     * Description:
     * <根据角色权限获取元素权限>
     * @author wupanhua
     * @date 10:10 2019/8/7
     * @return java.util.List<UserPermissUrlVo>
     **/
    List<UserPermissUrlVo> queryElementPermission();

    /**
     * Description:
     * <根据角色权限获取操作权限>
     * @author wupanhua
     * @date 10:11 2019/8/7
     * @return java.util.List<UserPermissUrlVo>
     **/
    List<UserPermissUrlVo> queryOperatePermission();

    /**
     * Description:
     * <根据角色主键删除角色权限表数据>
     * @author pig
     * @date 10:11 2019/8/7
     * @param id 1
     **/
    void deleteByRoleId(Long id);

    /**
     * Description:
     * <查询菜单是否有角色占用>
     * @author pig
     * @date 10:16 2019/8/7
     * @param id 1
     * @return int
     **/
    int queryMenuPermissionCountById(Long id);

    /**
     * Description:
     * <查询操作管理是否有角色占用>
     * @author pig
     * @date 10:16 2019/8/7
     * @param key 1
     * @return int
     **/
    int queryOperateOperatePermissionCountByKey(Long key);

    /**
     * Description:
     * <根据页面元素主键查询是狗有角色占用>
     * @author pig
     * @date 10:16 2019/8/7
     * @param key 1
     * @return int
     **/
    int queryElementPremissionCountByElementKey(Long key);

    /**
     * Description:
     * <无法补充>
     * @author wupanhua
     * @date 10:17 2019/8/7
     * @param free 1
     * @return java.util.List<RolePermission>
     **/
    List<RolePermission> queryPermissionByRoleKeys(List<Long> free);

    /**
     * Description:
     * <根据permissionid批量删除菜单权限>
     * @author wupanhua
     * @date 10:17 2019/8/7
     * @param mp 1
     **/
    void deleteMenuPermissionByPermissionIds(List<Long> mp);

    /**
     * Description:
     * <根据permissionid链批量删除页面元素权限>
     * @author wupanhua
     * @date 10:17 2019/8/7
     * @param ep 1
     **/
    void deleteElementPermissionByPermissionIds(List<Long> ep);

    /**
     * Description:
     * <根据permissionid链表批量删除操作元素权限>
     * @author wupanhua
     * @date 10:18 2019/8/7
     * @param op 1
     **/
    void deleteOperatePermissionByPermissionIds(List<Long> op);

    /**
     * Description:
     * <根据roleid链表批量删除角色权限表>
     * @author wupanhua
     * @date 10:18 2019/8/7
     * @param free 1
     **/
    void deleteRolePermissionByRoleIds(List<Long> free);

    /**
     * Description:
     * <批量查询菜单是否有角色占用>
     * @author pig
     * @date 10:18 2019/8/7
     * @param free 1
     * @return java.util.List<MenuPermission>
     **/
    List<MenuPermission> findMenuPermissionsByMenuKeys(List<Long> free);

    /**
     * Description:
     * <查询操作管理权限是否有角色占用>
     * @author pig
     * @date 10:19 2019/8/7
     * @param keys 1
     * @return java.util.List<OperatePermission>
     **/
    List<OperatePermission> findOperatesByOperateKeys(List<Long> keys);

    /**
     * Description:
     * <查询是否有角色占用页面元素权限>
     * @author pig
     * @date 10:19 2019/8/7
     * @param keys 1
     * @return java.util.List<ElementPermission>
     **/
    List<ElementPermission> findElementPermissionsByElementKeys(List<Long> keys);

    /**
     * Description:
     * <根据角色列表获取角色权限>
     * @author wupanhua
     * @date 10:19 2019/8/7
     * @param roles 1
     * @return java.util.List<RolePermission>
     **/
    List<RolePermission> findPermissionByRoleList(List<Role> roles);

    /**
     * Description:
     * <根据角色权限获取菜单列表>
     * @author wupanhua
     * @date 10:20 2019/8/7
     * @param role 1
     * @param permissionTypeCode 2
     * @return java.util.List<Menu>
     **/
    List<Menu> findMenuByRoleKeyAndPermissionType(@Param("roles") List<Role> role, @Param("permissionTypeCode") String permissionTypeCode);

    /**
     * Description:
     * <根据角色和权限编码获取页面元素列表>
     * @author wupanhua
     * @date 10:20 2019/8/7
     * @param roles 1
     * @param code 2
     * @return java.util.List<Element>
     **/
    List<Element> findElementByRoleKeyAndPermissionType(@Param("roles") List<Role> roles, @Param("code") String code);

    /**
     * Description:
     * <根据角色和权限编码获取操作权限>
     * @author wupanhua
     * @date 10:21 2019/8/7
     * @param roles 1
     * @param code 2
     * @return java.util.List<Operate>
     **/
    List<Operate> findOperateByRoleKeyAndPermissionType(@Param("roles") List<Role> roles, @Param("code") String code);

    /**
     * Description:
     * <根据菜单主键和角色权限表主键获取菜单权限数量>
     * @author wupanhua
     * @date 10:21 2019/8/7
     * @param menuKey 1
     * @param rolePermissionKey 2
     * @return int
     **/
    int queryMenuPermissionNumberByMenuKeyAndRolePermKey(@Param("menuKey") Long menuKey, @Param("rolePermissionKey") Long rolePermissionKey);

    /**
     * Description:
     * <根据角色列表获取元素权限>
     * @author 周婷婷
     * @date 10:21 2019/8/7
     * @param roles 1
     * @return java.util.List<UserPermissionVo>
     **/
    List<UserPermissionVo> queryElementPermissionByRole(List<Role> roles);

    /**
     * Description:
     * <根据角色列表获取操作权限>
     * @author 周婷婷
     * @date 10:22 2019/8/7
     * @param roles 1
     * @return java.util.List<UserPermissionVo>
     **/
    List<UserPermissionVo> queryOperatePermissionByRole(List<Role> roles);
}
